import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],

  // 开发服务器配置
  server: {
    // 代理
    proxy: {
      "/app-dev": {
        target: "http://gmall-h5-api.atguigu.cn",
        changeOrigin: true,
        // 路径是否需要重写，看接口文档（接口需要前缀，就不重写）（接口不需要前缀，就要重写）
        rewrite: (path) => path.replace(/^\/app-dev/, ""),
      },
    },
  },
});
